In [2]:
from __future__ import division
from functions import *
from utils import *
from gevi_classes import *

%matplotlib inline
%load_ext autoreload
%autoreload 2
In [3]:
%%javascript
IPython.OutputArea.auto_scroll_threshold = 1000;
In [4]:
# instantiate utility class
gr = Graph()

Load DATA

Data collected in 5 X 1min, with 1min pause in between 2921 images obtained in 60s

In [5]:
username = os.path.expanduser('~').split('/')[-1]
if username == "GP1514":
    print("At Imperial")
    mouseAPath = '/Volumes/DATA/DATA/Equalized Separation/2014 Oct 27/'
    mouseBPath = '/Volumes/DATA/DATA/Equalized Separation/2014 Oct 22/'
    mouseCPath = '/Volumes/DATA/DATA/Equalized Separation/2014 Oct 22/'
else:
    print("Using laptop")
    mouseAPath = '/Users/guillaume/Projects/GEVI-DATA/2014 Oct 27/'
    mouseBPath = '/Users/guillaume/Projects/GEVI-DATA/2014 Oct 22/'
    mouseCPath = '/Users/guillaume/Projects/GEVI-DATA/2014 Oct 28/'
At Imperial
In [6]:
discard = {
    'MouseA': 
    {
        3 : [0,1], 
        4 : [1,2], 
        5 : [2],
        6 : [2,3,4]
    }, 
    'MouseB' : 
    {
        3 : [2,4,5],
        4 : [1,2]
    }
}
# my choice
discard = {
    'MouseA': 
    {
        3 : [0,1,3], 
#         4 : [], 
#         5 : [],
        6 : [1]
    }, 
    'MouseB' : 
    {
        3 : [1,4],
#         4 : []
    },
    'MouseC' :
    {}
}
In [7]:
mouseA = Mouse('mouseA', mouseAPath, [3,4,5,6],discard['MouseA'] )
mouseB = Mouse('mouseB', mouseBPath, [2,3,4,5],discard['MouseB'] )
mouseC = Mouse('mouseC', mouseCPath, [4],discard['MouseC'] )

# filtering parameters
# mouseA.minFreqAlpha = 1
# mouseA.maxFreqAlpha = 200
mouseB.minFreqAlpha = 1
mouseB.maxFreqAlpha = 200
mouseA.window = 10
gr.fHmax = 30
gr.fRmax = 200
In [8]:
# mouseA.loadData()
mouseB.loadData()
# mouseC.loadData()
In [9]:
r = mouseB.experiments[0].repeats[0].ratio
h = mouseB.experiments[0].repeats[0].hemo
m = mouseB.experiments[0].repeats[0].mask
In [10]:
r.shape
Out[10]:
(2921, 60, 80)

Masks

In [11]:
fig = plt.figure()
ax = fig.add_subplot(131)
ax.imshow(m)
ax.set_title('rep 1, exp 2 , mouseB')
ax = fig.add_subplot(132)
ax.imshow(mouseB.experiments[0].expMask)
ax.set_title('mean all repeats')

ax = fig.add_subplot(133)
mouseB.setMask()
ax.imshow(mouseB.mouseMask)
ax.set_title('mouseB')
Out[11]:
<matplotlib.text.Text at 0x169ac5990>

Applying mask on hemo / ratio images

In [12]:
fig = plt.figure()
ax = fig.add_subplot(121)
ax.imshow(mouseB.experiments[0].ratioMasked[1][0])
ax.set_title('Masked ratio')
ax = fig.add_subplot(122)
ax.imshow(mouseB.experiments[0].hemoMasked[1][0])
ax.set_title('Masked hemo')
Out[12]:
<matplotlib.text.Text at 0x16ac77e10>

mean value of full region / of masked region for 100 frames

In [28]:
plt.figure()
x = xax(mouseB.experiments[0].repeats[0].mHemo[0:200],int(60000*200/2912))
ax1 = plt.subplot2grid((1,3), (0,0), colspan=2)
ax2 = plt.subplot2grid((1,3), (0,2))


ax1.plot(x,mouseB.experiments[0].repeats[0].mRatio[0:200], label='ratio')
ax1.plot(x,mouseB.experiments[0].repeats[0].mRatioUnmasked[0:200], label='outside masked ratio')
ax1.plot(x,mouseB.experiments[0].repeats[0].mRatioMasked[0:200], label='masked ratio')

ax1.legend(loc='best')
ax1.set_title('mean ratio vs mean masked ratio vs outside mask')

ax2.imshow(mouseB.experiments[0].repeats[0].mask)
ax2.set_title('Mask')


plt.figure()
ax1 = plt.subplot2grid((1,3), (0,0), colspan=2)
ax2 = plt.subplot2grid((1,3), (0,2))


ax1.plot(x,mouseB.experiments[0].repeats[0].mHemo[0:200], label='ratio')
ax1.plot(x,mouseB.experiments[0].repeats[0].mHemoUnmasked[0:200], label='outside masked hemo')
ax1.plot(x,mouseB.experiments[0].repeats[0].mHemoMasked[0:200], label='masked hemo')

ax1.legend(loc='best')
ax1.set_title('mean hemo vs mean masked hemo vs outside mask')

ax2.imshow(mouseB.experiments[0].repeats[0].mask)
ax2.set_title('Mask')

# alpha
plt.figure()
x = xax(mouseB.experiments[0].repeats[0].alpha,60000)
plt.plot(x,mouseB.experiments[0].repeats[0].alpha, label='alpha')
plt.plot(x,mouseB.experiments[0].repeats[0].alphaUnmasked, label='outside masked alpha')
plt.plot(x,mouseB.experiments[0].repeats[0].alphaMasked, label='masked alpha')

plt.legend(loc='best')
plt.title('mean ratio vs mean masked alpha')
Out[28]:
<matplotlib.text.Text at 0x1744c7690>
In [ ]:
 
In [24]:
al = np.fft.ifft(np.fft.fft(mouseB.experiments[0].repeats[0].mHemo)/ \
                 np.fft.fft(mouseB.experiments[0].repeats[0].mRatio))
plt.plot(movingaverage(al,10))

alu = np.fft.ifft(np.fft.fft(mouseB.experiments[0].repeats[0].mHemoUnmasked)/ \
                  np.fft.fft(mouseB.experiments[0].repeats[0].mRatioUnmasked))
plt.plot(movingaverage(alu,10))
alm = np.fft.ifft(np.fft.fft(mouseB.experiments[0].repeats[0].mHemoMasked)/ \
                  np.fft.fft(mouseB.experiments[0].repeats[0].mRatioMasked))
plt.plot(movingaverage(alm,10))
Out[24]:
[<matplotlib.lines.Line2D at 0x16e3e0f90>]
In [15]:
plt.figure()
plt.imshow(maskfn(mouseB.experiments[0].repeats[0].ratio, mouseB.experiments[0].repeats[0].mask )[0])
Out[15]:
<matplotlib.image.AxesImage at 0x11327f150>

With mask

In [29]:
gr.plotTF(mouseB,mask=True)

Without mask

In [30]:
gr.plotTF(mouseB,mask=False)
In [ ]: